Miles Sound System SDK 7.2a

Callbacks on Playstation 3

Discussion

Read this section carefully if you plan to use Miles timer or other callbacks (such as an end-of-sample callback). If you don't intend to use callbacks, then this section won't apply to you.

On the PS3, callbacks are usually made to your application on a background thread. The ideal callback function is one that does nothing more than write to one or two flag variables and then immediately return back to Miles.

So, unlike MacOS 9, Wii or PS2, you can do most of what you want inside a Miles callback on the PS3 - there are few OS-mandated restrictions. However, if you want to maintain easily ported code, then you should read about the callback restrictions for the other platforms you intend to support. Other platforms are much more strict than the PS3 when it comes to callbacks.

In any case, you do have to take general multithread precautions in your callbacks. For example, if you use the C runtime library inside a callback, then you need to link with the multithreaded libraries. If you access your own internal data structures, then you need to make sure that the accessor functions can be called by two threads at once (unless you protect with a critical section lock).

Also remember that all global or static variables that are modified by a callback function must be declared with the volatile modifier. Otherwise, the callback function and the foreground may not be able to communicate after the compiler has performed all of its optimizing tricks.

You should also minimize the total amount of work inside a Miles callback. During a callback, Miles is suspended, so other background tasks won't run - mixing will be interrupted, for example, if you take too long.

Again, though, the best advice for callbacks is to simply post a message or set a flag that can be operated on by your foreground task. This technique works on all platforms and you'll never need to worry about the complications that multithreading can cause.

Next Topic (Call Logging under PlayStation 3)

Previous Topic (Memory management under PlayStation 3)


Group: Overview for Sony PlayStation 3
Related FAQs: What's the deal with callbacks - are they threads, interrupts, system timers, or what?

For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.